{% extends "base.html" %}
{% block header %}添加用户{% endblock %}
{% block content %}
<div class="row justify-content-center">
    <div class="">
        <div class="card shadow-sm rounded p-4">
            <h4 class="mb-3">添加用户</h4>
            {% if error %}
            <div class="alert alert-danger">{{ error }}</div>
            {% endif %}
            <form method="post">
                {% csrf_token %}
                <div class="mb-3">
                    <label for="username" class="form-label">用户名</label>
                    <input type="text" class="form-control" id="username" name="username" required>
                </div>
                <div class="mb-3">
                    <label for="realname" class="form-label">姓名</label>
                    <input type="text" class="form-control" id="realname" name="realname" required>
                </div>
                <div class="mb-3">
                    <label for="email" class="form-label">邮箱</label>
                    <input type="email" class="form-control" id="email" name="email" required>
                </div>
                <div class="mb-3">
                    <label for="password" class="form-label">密码</label>
                    <input type="password" class="form-control" id="password" name="password" required>
                </div>
                <div class="mb-3">
                    <label for="user_type" class="form-label">用户类型</label>
                    <select class="form-select" id="user_type" name="user_type" required>
                        <option hidden value="user">普通用户</option>
                        <option value="config_user">配置用户</option>
                        <option value="admin">管理员</option>
                    </select>
                </div>
                <div class="mb-3">
                    <label for="is_active" class="form-label">是否启用</label>
                    <select class="form-select" id="is_active" name="is_active">
                        <option value="True" selected>启用</option>
                        <option value="False">禁用</option>
                    </select>
                </div>
                <!-- 只允许添加管理员，隐藏超级管理员选项 -->
                <div class="mb-3">
                    <label for="receiver" class="form-label">收件人</label>
                    <input type="text" class="form-control" id="receiver" name="receiver">
                </div>
                <div class="mb-3">
                    <label for="delivery_phone" class="form-label">联系电话</label>
                    <input type="text" class="form-control" id="delivery_phone" name="delivery_phone">
                </div>
                <div class="mb-3">
                    <label for="delivery_address" class="form-label">收货地址</label>
                    <input type="text" class="form-control" id="delivery_address" name="delivery_address">
                </div>
                <button type="submit" class="btn btn-success ">添加</button>
                <a href="/users/" class="btn btn-secondary ">返回用户列表</a>
            </form>
        </div>
    </div>
</div>
{% endblock %}
